package com.briup.service.Impl;

import com.briup.bean.Shop;
import com.briup.bean.ShopCar;
import com.briup.dao.IShopDao;
import com.briup.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class IShopServiceImpl implements IShopService {
    @Autowired
    private IShopDao shopDao;
    @Override
    public List<Shop> findAllShops() {
        List<Shop> shopList = shopDao.findByDiscountOrderBySalesVolumeDesc(false);
        return shopList;
    }

    @Override
    public Shop findShopById(Long id) {
        return shopDao.findShopById(id);
    }

    @Override
    public List<Shop> findDiscount() {
        List<Shop> shopList = shopDao.findByDiscountOrderBySalesVolumeDesc(true);
        return shopList;
    }

    @Override
    public List<Shop> recommendShop(Long userId) {
        List<Shop> shopList = shopDao.findByDiscountOrderBySalesVolumeDesc(true);
        return shopList;
    }

    @Override
    public List<Shop> findByCategory(Long category) {
        return shopDao.findByCategoryId(category);
    }

    @Override
    public List<Shop> searchShop(String shopName) {
        return shopDao.findByNameContaining(shopName);
    }

    @Override
    public void updateSalesVolume(List<ShopCar> list) {
        shopDao.updateSalesVolume(list);
    }

    @Override
    public void updateVisitVolume(Long shopId) {
        shopDao.updateVisitVolume(shopId);
    }

    @Override
    public void updateStockNum(List<ShopCar> list) {
        shopDao.updateStockNum(list);
    }
}
